package org.scau.studentevaluation.tool;

import java.time.LocalDateTime;

/**
 * @author little_cai
 * @date 2020/8/29 15:31
 **/
public class DateString {

        public LocalDateTime toDate(String date) {
            String strDate = date;
            int a = 0;
            int b = 0;
            int c = 0;
            int d = 0;
            int year = 0;

            int e = 0;
            int f = 0;
            int month = 0;

            int g = 0;
            int h = 0;
            int day = 0;

            int i = 0;
            int j = 0;
            int hour = 0;

            int k = 0;
            int l = 0;
            int min = 0;


            char year4 = strDate.charAt(0);
            a = (int) year4 - (int) ('0');
            char year3 = strDate.charAt(1);
            b = (int) year3 - (int) ('0');

            char year2 = strDate.charAt(2);
            c = (int) year2 - (int) ('0');

            char year1 = strDate.charAt(3);
            d = (int) year1 - (int) ('0');

            year = a * 1000 + b * 100 + c * 10 + d;

            char month2 = strDate.charAt(5);
            e = (int) month2 - (int) ('0');

            char month1 = strDate.charAt(6);
            f = (int) month1 - (int) ('0');

            month = e * 10 + f;

            char day2 = strDate.charAt(8);
            g = (int) day2 - (int) ('0');
            char day1 = strDate.charAt(9);
            h = (int) day1 - (int) ('0');
            day = g * 10 + h;

            char hour2 = strDate.charAt(11);
            i = (int) hour2 - (int) ('0');
            char hour1 = strDate.charAt(12);
            j = (int) hour1 - (int) ('0');
            hour = i * 10 + j;

            char min2 = strDate.charAt(14);
            k = (int) min2 - (int) ('0');
            char min1 = strDate.charAt(15);
            l = (int) min1 - (int) ('0');
            min = k * 10 + l;

            LocalDateTime dateTime = LocalDateTime.of(year, month, day, hour, min, 00);
            return dateTime;
        }
    }

